package com.example.shopping.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.shopping.dao.OrderDetailsDao;
import com.example.shopping.pojo.domain.OrderDetailsBean;
import com.example.shopping.pojo.vo.DetailsVo;
import com.example.shopping.service.OrderDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Dream
 * @version 1.0
 * @date 2020/11/9 12:58
 */
@Service
public class OrderDetailsServiceImpl extends ServiceImpl<OrderDetailsDao,OrderDetailsBean> implements OrderDetailsService {
    @Autowired
    private OrderDetailsDao orderDetailsDao;

    /**
     * 添加订单详情
     * @param list
     */
    @Override
    public void addDetails(List<OrderDetailsBean> list,Integer orderId) {
        for(int i=0;i<list.size();i++){
            list.get(i).setOrderId(orderId);
        }
        orderDetailsDao.addDetails(list);
    }

    /**
     * 查询订单详情
     * @param orderId
     * @return
     */
    @Override
    public List<DetailsVo> getByOrderId(Integer orderId) {
        return orderDetailsDao.getByOrderId(orderId);
    }
}
